package com.zjitc.serviceoss.controller;

import com.zjitc.common.utils.RespBean;
import com.zjitc.serviceoss.service.IOssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RequestMapping("oss")
@RestController
@Api(tags = "阿里云OSS")
public class OssController {

    @Autowired
    private IOssService iOssService;

    @PostMapping("upload-img")
    @ApiOperation("上传文件")
    public RespBean uploadImg(MultipartFile file, String cateDir) {

        String url = iOssService.uploadImg(file, cateDir);

        return RespBean.success().data("url", url).msg("上传文件成功");
    }
}
